﻿using Common.AspNetCore;
using Common.Infrastructure;
using Common.RunModels.Base;
using Microsoft.AspNetCore.Mvc;
using StatsData.Api.Models.BoardQuery;
using StatsData.Api.Service;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace StatsData.Api.Controllers
{
    [Route("api/BoardQuery")]
    public class BoardQueryController : ApiController
    {
        private readonly BoardQueryService boardQueryService;

        public BoardQueryController(BoardQueryService boardQueryService, IServiceProvider provider)
             : base(provider)
        {
            this.boardQueryService = boardQueryService;
        }

        /// <summary>
        /// 品质日看板获取CSI数据
        /// </summary>
        /// <param name="apiParam"></param>
        /// <returns></returns>
        [HttpPost, Route("GetCSIByQcBoard")]
        public async Task<ApiActionResult<List<QCBoardCSIRecordResultModel>>> GetCSIByQcBoard([FromBody] QCBoardCSIRecordParamModel apiParam)
        {
            return await SafeExecuteAsync(async (param) =>
            {
                return await this.boardQueryService.GetCSIByQcBoardAsync(apiParam);
            });
        }
    }
}
